package com.ruoyi.register.controller;

import com.ruoyi.register.entily.User;
import com.ruoyi.register.result.Result;
import com.ruoyi.register.service.RegisterService;
import com.ruoyi.register.utils.AliyunOssUtil;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("register")
public class RegisterController {
    @Resource
    RegisterService registerService;

    @RequestMapping("registerInserts")
    public Result registerInserts(@RequestBody User user){
        Result result = registerService.insert(user);
        return result;
    }

    @PostMapping("image")
    public Result image(@RequestPart("file") MultipartFile file) {
        AliyunOssUtil oss = AliyunOssUtil.OSS();
        String upload = oss.upload(file);
        User user = new User();
        user.setImage(upload);
        return new Result(true,5544, "ssss", user);
    }
}
